<?php 
//print_r($HttpResult);
if(1==2){$HttpResult = new HttpResult();}

	  $HttpContentResult = $HttpResult->getHttpContentResult();
	  //Debug::print_r($HttpResult);
	  //$lang = Config::DEFAULT_LOCALE;
		$head = new HtmlHeader($HttpContentResult->getHeader());
		$head->addCSS('reset');
		$head->addCSS('print','', 'print');
		$head->addCSS('ie',  'css/ie', 'print',true);
		
		$head->addCSS('forum',"css/admin");		
		
		//<!-- PROGRAMACAO JS | JQUERY  -->
		$head->addJS(array('jquery', 'masked'));
		
    //MENU DROPDOWN
    $head->addJS('Menu principal','js/menu/ddsmoothmenu');
    $head->addCSS('Menu CSS','js/menu/ddsmoothmenu');
    
    //TINYMCE
    $head->addJS('tinymce','js/tinymce/jquery.tinymce');
    
    //FILEUPLOAD
    $head->addJS('so','js/uploadify/swfobject');
    $head->addJS('uploadify','js/uploadify/jquery.uploadify.v2.1.4.min');
    $head->addCSS('Upload CSS','js/uploadify/uploadify');
		       
		//SLIDER SHOW
		$head->addJS('cycle', 'js/cycle/jquery.cycle.min');
	
		//<!-- JQUERY UI  -->
		$head->addJS('UI', 'js/UI/js/jquery-ui-1.8.6.custom.min');
		$head->addCSS('UI','js/UI/css/smoothness/jquery-ui-1.8.6.custom');
		
     //SELECTMENU
    $head->addJS('selectmenu','js/UI/development-bundle/ui/jquery.ui.selectmenu');
    $head->addCSS('selectmenu CSS','js/UI/css/jquery.ui.selectmenu');
    
		//<!-- VTIP  -->
		$head->addJS('vtip', 'js/vtip/vtip');
		$head->addCSS('vtip', 'js/vtip/vtip');
		
		//<!-- TABLE SORTER -->
		$head->addJS('tablesorter', 'js/tablesorter/tablesorter');
		$head->addCSS('tablesorter', 'js/tablesorter/tablesorter');
    
    //<!-- PROGRAMACAO JS | JQUERY  -->
    $head->addJS(array('admin','admin_select', 'admin/partner_admin/list'));
		
		$header_html = $head->show(TRUE);
$header_html = str_replace(array("democrart", "democrArt", "Democrart", "DemocrArt"), array("expressaoartistica", "Expressão Artística", "Expressão Artística", "Expressão Artística"), $header_html);
echo $header_html;
		
?>
 
<body>

<div id="main">
      <?php include "view/democrart/parts/admin/header.php" ?>
      
	  <div id="main_content">
	  
	  <div id="msgBox"></div>
	  			
		 <div id="box_right">
			<h1>Lista de <?php
				//agora o tratamento para o tipo de parceiros
				$type = "".$HttpContentResult->type;
				$type_page = "Parceiros Geral ";
				if($type == PartnerVO::PARTNER_TYPE_ARQUITETOS_E_DECORADORES){
					$type_page = "Arquitetos e Decoradores ";		
				} else if($type == PartnerVO::PARTNER_TYPE_SITE){
					$type_page = "Parceiros Site ";
				}
				echo $type_page;
				//tratamento para o título da página
				$active = "".$HttpContentResult->active;
				$active_name_page = "[TODOS]";
				if($active == "1"){
					$active_name_page = "Ativos";		
				}
				if($active == "0"){
					$active_name_page = "a Moderar";		
				}
				if($active == "-1"){
					$active_name_page = "Inativos";		
				}
				echo $active_name_page;
				//Filtros - verifica pela url
				DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "email");
				DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "nome");
				DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "profissao");
				
			?></h1>
			
			
			<?php
			$user_type 	= (DataHandler::getValueByArrayIndex($_POST, "user_type") != NULL)?DataHandler::getValueByArrayIndex($_POST, "user_type"):"2";
			
			// if(DataHandler::getValueByArrayIndex($this->arrayVariable, "user_type") != NULL){
				// $user_type = DataHandler::getValueByArrayIndex($this->arrayVariable, "user_type");
			// }
			$active 	= (DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "active"))?"/active.".DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "active"):"";
					$type		= (DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "type"))?"/type.".DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "type"):"";
					$baseURL	= Config::getRootPath("admin/partner_admin{$active}{$type}/");
					
			if(DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "name") || DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "email")){
				$filter 			= (DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "name"))?"Nome":"e-mail";
				$filtered_value 	= (DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "name"))?
										DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "name"):
										DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "email");
				
			?>
			
			<div id="avisoFiltroPartner">Procurado por: <?php echo $filter.": ".$filtered_value;?> - 
			<a href="<?php 
					
					echo $baseURL;
					?>">
				 remover procura <img src="<?php echo Config::getAsset("assets/img/icons/delete.jpg");?>" alt="remover filtro"></img>
			</a>
			</div>
			<br />
			<?php } ?>
			
			<form id="frmFilter" name="frmFilter" method="post" action="<?php echo Config::getRootPath("admin/partner_admin/active.".$HttpContentResult->active)?>" class="filter">
				<br />
				<strong>Procurar: </strong>
				<br />
				<br />
				<input type="text" name="filter" id="filter" size="25" />
				<select name="filter_by" id="filter_by">
					<option  value="name">Nome</option>
					<option  value="email" selected="selected" >Email</option>
				</select>
				
				<input type="button" onclick="window.location.href='<?php 
						//verificando se passou active e type para manter
						echo $baseURL;;
						?>'+$('#filter_by :selected').val()+'.'+$('#filter').val()" value="Procurar"  class="button">
			</form>
			
			<br />						
			<a style="float: right;margin: 10px 5px;" href="<?php echo Config::getRootPath("admin/partner_admin/insert") ?>" class="button">Novo Parceiro</a>
			
			<div style="clear:both">
			<form id="frmFilter" name="frmFilter" method="post" action="#" class="filter">
				<table>
					<tr>
						<td><span class="count"><?php echo $HttpContentResult->count_total; ?> registro(s)</span></td>
					</tr>
				</table>
				
				</form>
				<?php
			if(count($HttpContentResult->arrayUsers) > 0){
				?>
				<table class="tablesorter">
					<thead>
						<tr>
							<th>id</th>
							<th>Nome</th>
							<th>E-mail / Login</th>
							<th>Senha</th>
							<th>Profissão</th>
							<th>Telephone</th>
							<th>Vendas</th>
							<th>Transferir</th>
							<th>Editar</th>
							<th>Excluir</th>
						</tr>
					</thead>
					<tbody>
					<?php 
					// Debug::print_r($HttpContentResult);
					// exit();
					
					
						foreach($HttpContentResult->arrayUsers as $user){?>
							<tr id="user_<?php echo $user->id ?>">
								<td><?php echo $user->id; ?></td>
								<td><?php echo $user->name; ?></td>
								<td><?php echo $user->email; ?></td>
								<td><?php echo $user->password; ?></td>
								<td><?php echo $user->getProfession(); ?></td>
								<td><?php echo $user->phone; ?></td>							
								<td><a href="<?php echo Config::getRootPath('admin/afiliate_salles/active.1/filtro.partner_id/busca.'.$user->id); ?>">Ver vendas</a></td>
								<td><a href="<?php echo Config::getRootPath('admin/money_history/send_money/id.'.$user->id); ?>">($)</a></td>
								<td class="ico"><a href="<?php echo Config::getRootPath("admin/partner_admin/update/id.".$user->id) ?>">
								<img id="edit1" src="<?php echo Config::getAsset("assets/img/icons/edit.jpg");?>" alt="Editar" title="" /></a></td>
								<td class="ico"><a class="del" name="user" id="<?php echo $user->id ?>" href="<?php echo Config::getRootPath("admin/partner_admin/delete/id.".$user->id) ?>">
								<img id="del1" src="<?php echo Config::getAsset("assets/img/icons/delete.jpg");?>" alt="Excluir" title="" /></td>
							</tr>
						<?php }
					
						?>
					</tbody>
				</table>
			<?php
			} else {
				//não tem nenhum parceiro
				?>
				<br />Nenhum parceiro encontrado
				<?php
			}//end if não tem parceiro
			?>
			</div>
			
			<!-- COMECO PAGINACAO -->
<!-- 			<div style="clear: both;"></div>
			<div id="model-pagination" style="text-align: center;padding: 20px 0px 20px 0px;">
			<?php 
				include_once("library/facil3/utils/Pagination.class.php");
				$Pagination = new Pagination($HttpContentResult->page, $HttpContentResult->limit_page, $HttpContentResult->count_total);
				$htmlPaginacao = $Pagination->getHtml();
				echo $htmlPaginacao;
			?> -->
			
			</div>
		
		</div>
					
			
			<!-- FIM DO QUADRO -->
	
	</div>
	
</div>

</body>
</html>
